/*! \file FrequentSubgraph.hpp */

#ifndef FREQUENTSUBGRAPH_HPP_INCLUDED
#define FREQUENTSUBGRAPH_HPP_INCLUDED

#include "Graph.hpp"
#include <vector>

namespace TopologicalLearner
{
/**
 * A frequent subgraph class that contains both the frequent subgraph (a Graph object)
 * and a vector of the ID's of all the graphs in a graph database that contains this subgraph.
*/
struct FrequentSubgraph
{

public:
    Graph G;
    std::vector<int> vGraphIDs;

    template<class Archive>
    void serialize(Archive &ar, const unsigned int version)
    {
        ar & vGraphIDs;
        ar & G;
    }

};


/*
 * Used for sorting a vector of pointers to constant frequent subgraph based on the
 * support (size of vGraphsIDs)
*/
struct CPFrequentSubgraph_Sorter {

private:
    bool m_bDesc;

public:
    CPFrequentSubgraph_Sorter(bool bDesc) : m_bDesc(bDesc) {}
    CPFrequentSubgraph_Sorter() { m_bDesc=false; }

    bool operator()(const FrequentSubgraph* left, const FrequentSubgraph* right) {
        if( !m_bDesc )
            return left->vGraphIDs.size() > right->vGraphIDs.size();
        else
            return left->vGraphIDs.size() < right->vGraphIDs.size();
    }
};

}

#endif // FREQUENTSUBGRAPH_HPP_INCLUDED
